package day05;

public class Test02 {
    public static void main(String[] args) {
        System.out.println("Hello Test05");

        int[] array={1,2,3,4,5};
        double avg=getAvg(array);
        System.out.println("该数组平均值："+avg);
     }
        public static double getAvg(int[] arr){
            double avg=0.0;
            //遍历数组，求和
            int sum=0;
            for(int i=0;i<arr.length;i++){
                System.out.println(arr[i]);
                sum+=arr[i];
            }
            System.out.println(sum);
            int num=arr.length;
            avg=sum/num;


            //元素和除以数组长度
            return avg;
        }

    
}
